Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

XFuTokenizer.h

Go to the documentation of this file.
00001 /*! \file 
00002  * X-Forge Util <br>
00003  * Copyright 2000-2003 Fathammer Ltd
00004  * 
00005  * \brief String tokenizer utility
00006  * 
00007  * $Id: XFuTokenizer.h,v 1.8 2003/03/20 13:19:59 jetro Exp $
00008  * $Date: 2003/03/20 13:19:59 $
00009  * $Revision: 1.8 $
00010  */
00011 
00012 #ifndef XFUTOKENIZER_H_INCLUDED
00013 #define XFUTOKENIZER_H_INCLUDED
00014 
00015 
00016 
00017 
00018 //! String tokenizer utility class.
00019 /*! Tokenizes strings by delimiters.
00020  *  \par Example of use:
00021  *  \code
00022  *  const CHAR blah[] = "some; string with ; different tokens";
00023  *  XFuTokenizer myTokens;
00024  *  myTokens.tokenize(blah, XFCSTR(";"));
00025  *  INT i;
00026  *  for (i = 0; i < myTokens.getTokenCount(); ++i)
00027  *      if (myTokens.tokenEqualsNocase(i, XFCSTR("String wIth")))
00028  *          printf("token number %d is our token", i);
00029  *  \endcode
00030  */
00031 class XFuTokenizer 
00032 {
00033 public:
00034     //! Constructor.
00035     XFuTokenizer();
00036     
00037     //! Destructor.
00038     ~XFuTokenizer();
00039     
00040     //! Tokenizes the input string.
00041     /*! Uses the characters in aSeparators as delimiters for tokens.
00042      */
00043     void tokenize(const CHAR *aBuffer, const CHAR *aSeparators);
00044     
00045     //! Tokenizes the input string.
00046     /*! Uses the ',' and '=' characters as delimiters for tokens.
00047      */
00048     void tokenize(const CHAR *aBuffer);
00049     
00050     //! Case sensitive matching of a token and given string.
00051     INT tokenEquals(INT32 aIdx, const CHAR *aCompareString);
00052     
00053     //! Case insensitive matching of a token and given string.
00054     INT tokenEqualsNocase(INT32 aIdx, const CHAR *aCompareString);
00055     
00056     //! Get the token count.
00057     INT32 getTokenCount();
00058     
00059     //! Get a pointer to a token (as zero-terminated string).
00060     const CHAR * getToken(INT32 aIdx);
00061     
00062     //! Get a duplicate of a token (as zero-terminated string).
00063     CHAR * duplicateToken(INT32 aIdx);
00064     
00065 private:
00066     //! Token strings.
00067     CHAR **mData;
00068     //! Number of token strings.
00069     INT32 mCount;
00070     //! Upcase function.
00071     CHAR upcase(CHAR i);
00072 };
00073 
00074 
00075 #endif // !XFUTOKENIZER_H_INCLUDED

   
X-Forge Documentation
Confidential
Copyright © 2002-2003 Fathammer
   
Documentation generated
with doxygen
by Dimitri van Heesch